#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
class Edge
{
    public:
    int to;
    int w;
    Edge *next;
    void set(int to,int w)
    {
        this->to=to;
        this->w=w;
    }
};

class Graph
{
    static const int MVN=307,MARCN=MVN*100;
    public:
    int vn,arcn;
    Edge *edge,*head[MVN];
    int ep;
    Graph()
    {
        init(0);
        edge=new Edge[MARCN];
    };
    void init(int n)
    {
        vn=n;
        arcn=ep=0;
        fill(head,head+MVN,(Edge*)NULL);
    }
    void addEdge(int vs,int vt,int w)
    {
        edge[ep].set(vt,w);
        edge[ep].next=head[vs];
        head[vs]=&edge[ep++];
        arcn++;
    }
};

class Sat
{
    static const int MVN=307;
    public:
    int order[MVN],low[MVN],cnt;
    int toDag[MVN],gn;
    Graph g,dag;
    vector<int> s,res;
    bool inStack[MVN];
    int chosen[MVN];
    void init(Graph &g)
    {
        this->g=g;
        dag.init(0);
    }
    void dfs(int pos)
    {
        order[pos]=low[pos]=cnt++;
        s.push_back(pos),inStack[pos] = true;
        for(Edge *e=g.head[pos];e;e=e->next)
        {
            if(order[e->to]==-1)
            {
                dfs(e->to);
                if(low[e->to]<low[pos]) low[pos]=low[e->to];
            }
            else if(order[e->to]<low[pos]&&inStack[e->to]) low[pos]=order[e->to];
        }
        if(order[pos]==low[pos])
        {
            int t;
            while(!s.empty())
            {
                t=s.back(),s.pop_back(),inStack[t]=false;
                toDag[t]=gn;
                res.push_back(t);
                if(t==pos) break;
            }
            gn++;
        }
    }
    void buildDag()
    {
        fill(order,order+g.vn,-1);
        fill(inStack,inStack+g.vn,false);
        fill(toDag,toDag+g.vn,-1),gn=0;
        s.clear(),res.clear();
        cnt = 0;
        for(int i=0;i<g.vn;i++) if(order[i]==-1)
            dfs(i);
        dag.init(gn);
        for(int i=0;i<g.vn;i++)
            for(Edge *ep=g.head[i];ep;ep=ep->next) if(toDag[ep->to]!=toDag[i])
                dag.addEdge(toDag[ep->to],toDag[i],0);
    }
    bool legal()
    {
        for(int i=0;i<g.vn;i++) if(toDag[i]==toDag[i^1])
            return false;
        return true;
    }
    void pickOut(int gi)
    {
        chosen[gi]=0;
        for(Edge *ep=dag.head[gi];ep;ep=ep->next) if(chosen[ep->to])
        {
            pickOut(ep->to);
        }
    }
    void getChosen()
    {
        fill(chosen,chosen+dag.vn,1);
        for(int i=0,vi;i<res.size();i++)
        {
            vi=res[i];
            if(chosen[toDag[vi]]==1)
            {
                pickOut(toDag[vi^1]);
                chosen[toDag[vi]]=2;
            }
        }
    }
};

int main()
{
    int n,m;
    Graph g;
    Sat ft;
    while(cin>>n>>m)
    {
        if(!n&&!m)break;
        g.init(n*2);
        while(m--)
        {
            char c1,c2;
            int v1,v2;
            scanf("%d%c %d%c",&v1,&c1,&v2,&c2);
            v1*=2,v2*=2;
            if(c1=='w') v1++;
            if(c2=='w') v2++;
            g.addEdge(v1,v2^1,0);
            g.addEdge(v2,v1^1,0);
        }
        g.addEdge(1,0,0);
        ft.init(g);
        ft.buildDag();
        if(!ft.legal())cout<<"bad luck"<<endl;
        else
        {
            ft.getChosen();
            for(int i=2;i<g.vn;i+=2)
            {
                if(!ft.chosen[ft.toDag[i]]) cout<<i/2<<"h ";
                else cout<<i/2<<"w ";
            }
            cout<<endl;
        }
    }
    return 0;
}
